home *** CD-ROM | disk | FTP | other *** search
/ Revista CD Expert 37 / CD Expert nº 37.iso / LastCall / lastcall.exe / stuff / lastcall.dxr / 00027_More scripts (split from Various).ls < prev    next >
Encoding:
Text File  |  2000-03-27  |  16.2 KB  |  692 lines

  1. on moveWindow
  2.   global gStageCorner
  3.   gStageCorner = point((the stage).rect.left, (the stage).rect.top)
  4. end
  5.  
  6. on SpriteToSoundChannel spriteNumber
  7.   return SpriteToBarSlot(spriteNumber)
  8. end
  9.  
  10. on SpriteToBarSlot spriteNumber
  11.   global gCharacterSprites
  12.   barSlot = getOne(gCharacterSprites, spriteNumber)
  13.   if (barSlot < 1) or (barSlot > count(gCharacterSprites)) then
  14.     debugAlert("Invalid bar slot number" && barSlot)
  15.     return 0
  16.   else
  17.     return barSlot
  18.   end if
  19. end
  20.  
  21. on glassSpriteToBarSlot spriteNumber
  22.   global gBarGlassSprites
  23.   barSlot = getOne(gBarGlassSprites, spriteNumber)
  24.   if (barSlot < 1) or (barSlot > count(gBarGlassSprites)) then
  25.     debugAlert("Invalid bar slot number" && barSlot)
  26.     return 0
  27.   else
  28.     return barSlot
  29.   end if
  30. end
  31.  
  32. on testActiveCharacter
  33.   global gCurrentIndex
  34.   gCurrentIndex = 1
  35.   updateDisplay()
  36. end
  37.  
  38. on updateDisplay skip
  39.   global gCurrentIndex
  40.   hilite line gCurrentIndex of field "ActionDisplay"
  41.   member("ListDisplay").text = string(currentActionSteps())
  42. end
  43.  
  44. on testRandom n
  45.   a = 0
  46.   b = 0
  47.   c = 0
  48.   repeat with X = 1 to n
  49.     z = randomFromWeightedList([6, 2, 2], [#a, #b, #c])
  50.     case z of
  51.       #a:
  52.         a = a + 1
  53.       #b:
  54.         b = b + 1
  55.       #c:
  56.         c = c + 1
  57.     end case
  58.   end repeat
  59.   put "a" && a
  60.   put "b" && b
  61.   put "c" && c
  62. end
  63.  
  64. on placeCursor newLoc
  65.   global gStageCorner
  66.   gStageCorner = point((the stage).rect.left, (the stage).rect.top)
  67.   newLoc = gStageCorner + newLoc
  68.   baPlaceCursor(newLoc[1], newLoc[2])
  69. end
  70.  
  71. on pourIntersection vesselSprite, bottleSprite, spoutLoc
  72.   hotRect = vesselSprite.rect
  73.   if bottleSprite = vesselSprite then
  74.     return 0
  75.   else
  76.     if inside(spoutLoc, hotRect) then
  77.       return 1
  78.     else
  79.       return 0
  80.     end if
  81.   end if
  82. end
  83.  
  84. on sendCharacter message, inSound, activeOnly
  85.   if activeOnly then
  86.     activeSprite = getActiveCharacter()
  87.     sendSprite(activeSprite, message, inSound)
  88.   else
  89.     sendAllSprites(message)
  90.   end if
  91. end
  92.  
  93. on getActiveCharacter
  94.   global gBarTopManager
  95.   if not objectp(gBarTopManager) then
  96.     return 0
  97.   else
  98.     return barSlotToSprite(getActiveSlot(gBarTopManager))
  99.   end if
  100. end
  101.  
  102. on getActiveGlass
  103.   if getActiveCharacter() = 0 then
  104.     return 0
  105.   else
  106.     return patronToGlass(getActiveCharacter())
  107.   end if
  108. end
  109.  
  110. on patronToGlass patronSprite
  111.   global gBarTopManager
  112.   return barSlotToGlassSprite(gBarTopManager, SpriteToBarSlot(patronSprite))
  113. end
  114.  
  115. on storeHelpPointerState
  116.   global gObeyHelpPointerstate
  117.   gObeyHelpPointerstate = 0
  118. end
  119.  
  120. on restoreHelpPointerState
  121.   global gObeyHelpPointerstate
  122.   gObeyHelpPointerstate = 1
  123. end
  124.  
  125. on toggleToolTips
  126.   global gHelpPointer
  127.   gHelpPointer = not gHelpPointer
  128.   if not gHelpPointer then
  129.     hideToolTip()
  130.   end if
  131. end
  132.  
  133. on goSoda
  134.   replaceDraggingAnything()
  135.   if inBonusMode() then
  136.     if marker(0) = label("SodaGunBonus") then
  137.       play done
  138.     else
  139.       play frame "SodaGunBonus"
  140.     end if
  141.   else
  142.     if marker(0) = label("SodaGun") then
  143.       returnToBar()
  144.     else
  145.       dismissToolTip(1)
  146.       go("SodaGun")
  147.     end if
  148.   end if
  149. end
  150.  
  151. on saveCursor newCursor
  152.   global gOldCursor
  153.   gColdCursor = the cursor of sprite 0
  154.   if voidp(newCursor) then
  155.     newCursor = resetCursor()
  156.   end if
  157.   if the cursor of sprite 0 <> newCursor then
  158.     cursor(newCursor)
  159.   end if
  160. end
  161.  
  162. on recreateCursor
  163.   global gColdCursor
  164.   if the cursor of sprite 0 <> gColdCursor then
  165.     cursor(gColdCursor)
  166.   end if
  167. end
  168.  
  169. on keyDown
  170.   global gSodaGun, gMatrixMode, gBarTopManager, gQuickPlayMode, gCurrentItem, gDraggingBottle, gThrottleRate, gPourThrottleRate, gEvenPouring, gMuteAllSounds, gSpoonSprite, gIceSprite, gGameLevel, gRecoverLastIngredient, gFloatSprite, debug, gPearlyGates, gGameLevelStartTime, gUserQuitFlag, gGameSetup, gBonusStartTime
  171.   case the key of
  172.     "[":
  173.       if authoring() or (debug = 1) then
  174.         gGameLevelStartTime = gGameLevelStartTime + minutes(1)
  175.         gBonusStartTime = gBonusStartTime + seconds(5)
  176.       end if
  177.     "{":
  178.       if authoring() or (debug = 1) then
  179.         gGameLevelStartTime = gGameLevelStartTime - minutes(1)
  180.         gBonusStartTime = gBonusStartTime - seconds(5)
  181.       end if
  182.   end case
  183.   case the key of
  184.     24:
  185.       nothing()
  186.       dontPassEvent()
  187.       exit
  188.   end case
  189.   if charToNum(the key) = 11 then
  190.     gMatrixMode = not gMatrixMode
  191.     gFloatSprite.trails = gMatrixMode
  192.   else
  193.     if (charToNum(the key) = 26) and authoring() then
  194.       returnToBar(#test)
  195.       exit
  196.     else
  197.       if (the keyCode = 53) or (charToNum(the key) = 17) then
  198.         quitSequence()
  199.         exit
  200.       end if
  201.     end if
  202.   end if
  203.   case the key of
  204.     "+", "=":
  205.       volumeUp()
  206.     "-", "_":
  207.       volumeDown()
  208.     "4", "5", "6", "7", "8", "9":
  209.       volumeSet(integer(the key))
  210.     "0":
  211.       toggleMute()
  212.   end case
  213.   if inMenuMode() then
  214.     if marker(0) = label("Main Menu") then
  215.       case the key of
  216.         "n", "g":
  217.           go("new game")
  218.           clickSound()
  219.         "l":
  220.           go("saved game")
  221.           clickSound()
  222.         "o":
  223.           go("options")
  224.           clickSound()
  225.         "h", "?", "/":
  226.           go("Help")
  227.           clickSound()
  228.         "s":
  229.           go("High Scores")
  230.           clickSound()
  231.         "q", "e":
  232.           quitTheProjector()
  233.         "d", "p":
  234.           sendSprite(132, #mouseUp)
  235.           clickSound()
  236.         "f":
  237.           sendSprite(133, #mouseUp)
  238.           clickSound()
  239.         "c":
  240.           go("Credits")
  241.           clickSound()
  242.         "x":
  243.           if the shiftDown and the mouseDown then
  244.             gGameLevel = 0
  245.             startNextLEvel()
  246.             returnToBar(#slotMachine)
  247.             clickSound()
  248.           end if
  249.         "k":
  250.           gMatrixMode = 1
  251.       end case
  252.       if the keyCode = 122 then
  253.         go("Help")
  254.         clickSound()
  255.       end if
  256.     end if
  257.     exit
  258.   end if
  259.   if gPearlyGates or gUserQuitFlag then
  260.     exit
  261.   end if
  262.   if the keyCode = 122 then
  263.     toggleHelpWindow(gCurrentItem)
  264.   end if
  265.   if not inBonusMode() then
  266.     Active = getActiveCharacter()
  267.   end if
  268.   case the key of
  269.     "a":
  270.       if not inBonusMode() then
  271.         sendSprite(Active, #toughLove)
  272.       end if
  273.     "b":
  274.       if the optionDown then
  275.         grabThisIngredient(#brandy)
  276.       else
  277.         if the shiftDown then
  278.           grabThisIngredient(#BITTERS)
  279.         else
  280.           if commandOrControlDown() then
  281.             grabThisIngredient(#raspberry)
  282.           else
  283.             grabThisIngredient(#bourbon)
  284.           end if
  285.         end if
  286.       end if
  287.     "c":
  288.       if the optionDown then
  289.         grabThisIngredient(#cocoRum)
  290.       else
  291.         if the shiftDown then
  292.           grabThisIngredient(#cachaca)
  293.         else
  294.           if commandOrControlDown() then
  295.             grabThisIngredient(#champ)
  296.           else
  297.             sendSprite(gSodaGun, #mChangeSoda, the key, 1)
  298.           end if
  299.         end if
  300.       end if
  301.     "d":
  302.       grabThisIngredient(#dryVermouth)
  303.     "e":
  304.       if modifierDown() then
  305.         quitGame()
  306.       else
  307.         if not inBonusMode() then
  308.           emptyGlasses(0, VOID, 1)
  309.         end if
  310.       end if
  311.     "f":
  312.       if not inBonusMode() then
  313.         if the shiftDown and draggingBottleThang() then
  314.           sendSprite(gDraggingBottle, #mFlip)
  315.         else
  316.           sendSprite(Active, #charm)
  317.         end if
  318.       end if
  319.     "g":
  320.       if the shiftDown then
  321.         grabThisIngredient(#GIN)
  322.       else
  323.         if commandOrControlDown() then
  324.           grabThisIngredient(#grapefruit)
  325.         else
  326.           if the optionDown then
  327.             grabThisIngredient(#grenadine)
  328.           else
  329.             sendSprite(gSodaGun, #mChangeSoda, the key, 1)
  330.           end if
  331.         end if
  332.       end if
  333.     "h":
  334.       if modifierDown() then
  335.         toggleHelpWindow(gCurrentItem)
  336.       else
  337.         toggleToolTips()
  338.       end if
  339.     "?", "/":
  340.       if not inBonusMode() then
  341.         toggleHelpWindow(gCurrentItem)
  342.       end if
  343.     "i":
  344.       if modifierDown() then
  345.         if not inBonusMode() then
  346.           sendSprite(Active, #card)
  347.         end if
  348.       else
  349.         if draggingBottleThang() then
  350.           if sprite(gDraggingBottle).pIngredient = #ice then
  351.             replaceDraggingAnything()
  352.           else
  353.             grabThisIngredient(#ice)
  354.           end if
  355.         else
  356.           grabThisIngredient(#ice)
  357.         end if
  358.       end if
  359.     "j":
  360.       goSoda()
  361.     "k":
  362.       if modifierDown() then
  363.         gMatrixMode = not gMatrixMode
  364.       else
  365.         grabThisIngredient(#kahfee)
  366.       end if
  367.     "l":
  368.       if the shiftDown then
  369.         grabThisIngredient(#limeWedge)
  370.       else
  371.         if commandOrControlDown() then
  372.           grabThisIngredient(#lemonWedge)
  373.         else
  374.           if the optionDown then
  375.             grabThisIngredient(#limetwist)
  376.           else
  377.             sendSprite(gSodaGun, #mChangeSoda, the key, 1)
  378.           end if
  379.         end if
  380.       end if
  381.     "m":
  382.       if the shiftDown then
  383.         grabThisIngredient(#melonLiquer)
  384.       else
  385.         if the optionDown then
  386.           grabThisIngredient(#mchino)
  387.         else
  388.           if commandOrControlDown() then
  389.             grabThisIngredient(#milk)
  390.           else
  391.             if draggingSpoon() then
  392.               replaceDraggingAnything()
  393.             else
  394.               replaceDraggingAnything()
  395.               grabThisIngredient(#spoon)
  396.             end if
  397.           end if
  398.         end if
  399.       end if
  400.     "n":
  401.       if not inBonusMode() then
  402.         if modifierDown() then
  403.           if not newCharacterEnters(#Always) then
  404.             alertBeep()
  405.           end if
  406.         else
  407.           removeGarnish()
  408.         end if
  409.       end if
  410.     "o":
  411.       if the shiftDown or inBonusMode() then
  412.         grabThisIngredient(#orange)
  413.       else
  414.         if commandOrControlDown() then
  415.           grabThisIngredient(#orangeWedge)
  416.         else
  417.           if the optionDown then
  418.             grabThisIngredient(#olive)
  419.           else
  420.             if not inBonusMode() then
  421.               sendSprite(Active, #order)
  422.             end if
  423.           end if
  424.         end if
  425.       end if
  426.     "p":
  427.       if commandOrControlDown() or the optionDown then
  428.         grabThisIngredient(#pschnap)
  429.       else
  430.         if the shiftDown then
  431.           grabThisIngredient(#pineapple)
  432.         else
  433.           if not inBonusMode() then
  434.             togglePourWindow()
  435.           else
  436.             grabThisIngredient(#pschnap)
  437.           end if
  438.         end if
  439.       end if
  440.     "q":
  441.       gQuickPlayMode = not gQuickPlayMode
  442.     "r":
  443.       if modifierDown() or inBonusMode() then
  444.         grabThisIngredient(#rum)
  445.       else
  446.         if not inBonusMode() then
  447.           if Active then
  448.             sendSprite(Active, #recipes)
  449.           else
  450.             toggleRecipeWindow("other", VOID, 0)
  451.           end if
  452.         end if
  453.       end if
  454.     "s":
  455.       if the optionDown then
  456.         grabThisIngredient(#soco)
  457.       else
  458.         if the shiftDown then
  459.           grabThisIngredient(#scotch)
  460.         else
  461.           if commandOrControlDown() then
  462.             if inBonusMode() then
  463.               grabThisIngredient(#scotch)
  464.             else
  465.               sendSprite(Active, #serve)
  466.             end if
  467.           else
  468.             sendSprite(gSodaGun, #mChangeSoda, the key, 1)
  469.           end if
  470.         end if
  471.       end if
  472.     "t":
  473.       if the optionDown or the shiftDown then
  474.         grabThisIngredient(#tequila)
  475.       else
  476.         if commandOrControlDown() then
  477.           grabThisIngredient(#tripleSec)
  478.         else
  479.           sendSprite(gSodaGun, #mChangeSoda, the key, 1)
  480.         end if
  481.       end if
  482.     "u":
  483.       soundFX("urine_into_mglass_wice", 0, 0)
  484.     "v":
  485.       if the optionDown then
  486.         grabThisIngredient(#dryVermouth)
  487.       else
  488.         if the shiftDown then
  489.           grabThisIngredient(#sweetVermouth)
  490.         else
  491.           grabThisIngredient(#vodka)
  492.         end if
  493.       end if
  494.     "w":
  495.       if modifierDown() then
  496.         grabThisIngredient(#whiskey)
  497.       else
  498.         sendSprite(gSodaGun, #mChangeSoda, the key, 1)
  499.       end if
  500.     "x":
  501.       if modifierDown() then
  502.         getAnXbottle()
  503.       else
  504.         sendSprite(gSodaGun, #mChangeSoda, the key, 1)
  505.       end if
  506.     "y":
  507.       if not inBonusMode() then
  508.         emptyGlasses(0, 1, 0)
  509.       end if
  510.     "z":
  511.       if modifierDown() then
  512.         grabThisIngredient(#salt)
  513.       else
  514.         grabThisIngredient(#SUGAR)
  515.       end if
  516.     "1", "2", "3":
  517.       if not inBonusMode() then
  518.         makePatronActive(integer(the key))
  519.       end if
  520.     TAB:
  521.       if not inBonusMode() then
  522.         makePatronActive(VOID, 1)
  523.       end if
  524.     RETURN:
  525.       returnToBar()
  526.     SPACE:
  527.       repeat while keyPressed(SPACE)
  528.         stopEvent()
  529.         updateStage()
  530.       end repeat
  531.       wasDragging = draggingAnything()
  532.       returnToBar()
  533.       if not wasDragging then
  534.         grabThisIngredient(gRecoverLastIngredient, VOID, the mouseLoc)
  535.       end if
  536.     "\", "|":
  537.       if modifierDown() then
  538.         gThrottleRate = min(20, gThrottleRate + 1)
  539.       else
  540.         gThrottleRate = max(1, gThrottleRate - 1)
  541.       end if
  542.     "`", "~":
  543.       if modifierDown() then
  544.         gPourThrottleRate = min(20, gPourThrottleRate + 1)
  545.       else
  546.         gPourThrottleRate = max(1, gPourThrottleRate - 1)
  547.       end if
  548.     "!":
  549.       gEvenPouring = not gEvenPouring
  550.     "]":
  551.       if authoring() or (debug = 1) then
  552.         gGameSetup[gGameLevel][#MINTIPS] = currentLevel(#MINTIPS) - currentLevel(#MAXFASTPERFECTTIP)
  553.       end if
  554.     "}":
  555.       if authoring() or (debug = 1) then
  556.         gGameSetup[gGameLevel][#MAXEARLYTIPS] = currentLevel(#MAXEARLYTIPS) - currentLevel(#MAXFASTPERFECTTIP)
  557.       end if
  558.   end case
  559. end
  560.  
  561. on getAnXbottle newLiquor
  562.   global gXbottlePopup
  563.   returnToBar()
  564.   xSprite = sprite(64)
  565.   if voidp(newLiquor) then
  566.     sendSprite(gXbottlePopup, #mShowPopup, xSprite, xSprite.pIngredient, the mouseLoc, newLiquor)
  567.   else
  568.     sendSprite(xSprite, #mUseXbottle, newLiquor)
  569.   end if
  570.   return xSprite.spriteNum
  571. end
  572.  
  573. on getLiquorBottle newLiquor, justLooking, pickupLoc
  574.   global gIngredients
  575.   if not justLooking then
  576.     returnToBar()
  577.   end if
  578.   if gIngredients[newLiquor][#Xbottle] then
  579.     if not justLooking then
  580.       getAnXbottle(newLiquor)
  581.     end if
  582.     return 0
  583.   end if
  584.   repeat with X = 32 to 37
  585.     if locateIngredient(X, newLiquor, justLooking) then
  586.       return X
  587.     end if
  588.   end repeat
  589.   repeat with X = 41 to 47
  590.     if locateIngredient(X, newLiquor, justLooking) then
  591.       return X
  592.     end if
  593.   end repeat
  594.   repeat with X = 56 to 75
  595.     if locateIngredient(X, newLiquor, justLooking, pickupLoc) then
  596.       return X
  597.     end if
  598.   end repeat
  599.   return 0
  600. end
  601.  
  602. on grabThisIngredient newIngredient, justLooking, pickupLoc
  603.   global gSodaGun, gSpoonSprite, gIceSprite
  604.   if not symbolp(newIngredient) then
  605.     exit
  606.   end if
  607.   if isGarnish(newIngredient) then
  608.     repeat with X = 32 to 37
  609.       if locateIngredient(X, newIngredient, justLooking) then
  610.         return X
  611.         next repeat
  612.       end if
  613.       if locateIngredient(X, twistIt(newIngredient), justLooking) then
  614.         return X
  615.       end if
  616.     end repeat
  617.   else
  618.     if isSodaIngredient(newIngredient) then
  619.       if not justLooking then
  620.         sendSprite(gSodaGun, #mChangeSoda, newIngredient, 1)
  621.       end if
  622.       return gSodaGun.spriteNum
  623.     else
  624.       if newIngredient = #spoon then
  625.         sendSprite(gSpoonSprite, #mPickMeUp)
  626.         return gSpoonSprite.spriteNum
  627.       else
  628.         if newIngredient = #ice then
  629.           sendSprite(gIceSprite, #mPickMeUp)
  630.           return gIceSprite.spriteNum
  631.         else
  632.           return getLiquorBottle(newIngredient, justLooking, pickupLoc)
  633.         end if
  634.       end if
  635.     end if
  636.   end if
  637. end
  638.  
  639. on locateIngredient X, newIngredient, justLooking, pickupLoc
  640.   if sprite(X).pIngredient = newIngredient then
  641.     if not justLooking then
  642.       sendSprite(X, #mPickMeUp, newIngredient, pickupLoc)
  643.     end if
  644.     return 1
  645.   end if
  646. end
  647.  
  648. on wait interval
  649.   startAt = nowTicks()
  650.   repeat while nowTicks() < (startAt + interval)
  651.   end repeat
  652. end
  653.  
  654. on monitor
  655. end
  656.  
  657. on diagnose
  658.   put sprite(getActiveCharacter()).pStepsInCurrentAction
  659.   put sprite(getActiveCharacter()).pActionList
  660. end
  661.  
  662. on gotoFlashFrame flashSprite, frameNum, updateMe
  663.   gotoFrame(flashSprite, frameNum)
  664.   if updateMe then
  665.     updateStage()
  666.   end if
  667. end
  668.  
  669. on stageBox
  670.   return rect(0, 0, (the stage).rect.width, (the stage).rect.height)
  671. end
  672.  
  673. on goFlash flashSprite, start, end
  674.   repeat while 1
  675.     exit = 0
  676.     repeat with X = start to end
  677.       gotoFlashFrame(sprite(flashSprite), X, 1)
  678.       if the mouseDown then
  679.         exit = 1
  680.         exit repeat
  681.       end if
  682.     end repeat
  683.     if exit = 1 then
  684.       exit repeat
  685.     end if
  686.   end repeat
  687.   put X
  688.   repeat while the stillDown
  689.     updateStage()
  690.   end repeat
  691. end
  692.